/**
 * @param {number} x
 * @return {boolean}
 */
function pickPeaks(arr) {
  let pos = []; let peaks = []; let stack = -1;
  for (i = 1; i < arr.length; i++) {
    if (arr[i] > arr[i - 1]) {
      stack = i
    } else if (arr[i] < arr[i - 1]) {
      if (stack != -1) {
        pos.push(stack)
        peaks.push(arr[stack])
      }
      stack = -1
    }
  }
  return { pos, peaks }
}


console.log(pickPeaks([1, 2, 3, 6, 4, 1, 2, 3, 2, 3, 3, 3]))
//  { pos: [3, 7], peaks: [6, 3] }
